#ifndef __GUI_SWITCH_H
#define __GUI_SWITCH_H

#define GUI_SWITCH_ITEM_NAME_LEN 12
#define GUI_SWITCH_ITEM_NUM 6

typedef enum
{
    GUI_SWITCH_ITEM_FIXED=1<<0, //switch item fix size
    GUI_SWITCH_ITEM_AUTO=1<<1, //all switch item are auto size
}gui_switch_flags_t;

typedef enum
{
    GUI_SWITCH_LEFT = 0, // left box
    GUI_SWITCH_RIGHT,    // right box
    GUI_SWITCH_TOP,      // top box
    GUI_SWITCH_BOTTOM,   // bottom box
} gui_switch_type_t;

typedef struct
{
    gui_spirit_t *spirit;
    gui_spirit_t content_spirit;
    gui_spirit_t icon; // item icon
    gui_color_t back_color;
    char name[GUI_SWITCH_ITEM_NAME_LEN]; // item name
    int item_x;
    int item_y;
    int item_width;
    int item_height;
} gui_switch_item_t;

typedef struct
{
    gui_spirit_t spirit;
    gui_spirit_t switch_spirit;
    gui_switch_item_t switch_item[GUI_SWITCH_ITEM_NUM]; // item
    gui_switch_type_t switch_type;
    gui_color_t back_color;
    gui_color_t switch_color;      // switch color
    gui_switch_item_t *cur_switch; // current item switched
    int width;
    int height;
    int content_width;
    int content_height;
    uint8_t padding;
    int x;
    int y;
    int content_x;
    int content_y;
    int flags;
} gui_switch_t;

typedef struct
{
    gui_switch_t *switch_obj;
    gui_switch_item_t *item;
} gui_switch_item_event_arg_t;

#define GUI_SWITCH(spirit) ((gui_switch_t *)(spirit))


gui_spirit_t *gui_switch_create(gui_switch_type_t type, int width, int height);
void gui_switch_show(gui_switch_t *switch_obj);
void gui_switch_item_register(gui_switch_item_t *item, gui_spirit_t *spirit);
void gui_switch_item_unregister(gui_switch_item_t *item, gui_spirit_t *spirit);
void gui_switch_item_show(gui_switch_item_t *item);
void gui_switch_get_content_pos(gui_switch_t *switch_obj, int *x, int *y);
void gui_switch_set_pos(gui_switch_t *switch_obj, int x, int y);
void gui_switch_get_pos(gui_switch_t *switch_obj, int *x, int *y);
void gui_switch_item_set_icon(gui_switch_item_t *item, char *icon);
void gui_switch_set_item_disable(gui_switch_t *switch_obj, gui_switch_item_t *item);
void gui_switch_set_item_enable(gui_switch_t *switch_obj, gui_switch_item_t *item);
void gui_switch_item_set_title(gui_switch_t *switch_obj, gui_switch_item_t *item, char *text, int len);
void gui_switch_item_draw(gui_switch_t *switch_obj, gui_switch_item_t *item);
void gui_switch_item_draw_all(gui_switch_t *switch_obj);
void gui_switch_draw(gui_switch_t *switch_obj);
gui_switch_item_t *gui_switch_item_find(gui_switch_t *swtich_obj,uint8_t item_idx);

#endif